﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Security;

using Bricks.Component.Utils;
using Bricks.Business.Models;
using Bricks.Site.Models;
using Bricks.Business.Service;
using Bricks.Business.Data.Repositories.EstimateManagement;
using Bricks.Business.Models.EstimateManagement;


namespace ChiDao.Business.Service.Impl
{
    [Export(typeof(IConstructionContractEstimateBillService))]
    internal class ConstructionContractEstimateBillService : IConstructionContractEstimateBillService
    {
        [Import]
        protected IConstructionContractEstimateBillRepository ConstructionContractEstimateBillRepository { get; set; }

        public List<ConstructionContractEstimateBillView> GetConstructionContractEstimateBillList(Guid ContractStagesID)
        {
            List<ConstructionContractEstimateBillView> lstConstructionContractEstimateBillView = new List<ConstructionContractEstimateBillView>();
            IQueryable<ConstructionContractEstimateBill> constructionContractEstimateBills = ConstructionContractEstimateBillRepository.Entities.Where(c => c.ContractStagesID == ContractStagesID);
            foreach (ConstructionContractEstimateBill constructionContractEstimateBill in constructionContractEstimateBills)
            {
                lstConstructionContractEstimateBillView.Add(new ConstructionContractEstimateBillView()
                {
                    ID = constructionContractEstimateBill.ID,
                    ContractStagesID = constructionContractEstimateBill.ContractStagesID,
                    BillCode = constructionContractEstimateBill.BillCode,
                    PorjectContent = constructionContractEstimateBill.PorjectContent,
                    ContractMoney = constructionContractEstimateBill.ContractMoney,
                    AlterChangeMoney = constructionContractEstimateBill.AlterChangeMoney,
                    AfterAlterMoney = constructionContractEstimateBill.AfterAlterMoney,
                    CurrentUnfinished = constructionContractEstimateBill.CurrentUnfinished,
                    LastUnfinished = constructionContractEstimateBill.LastUnfinished,
                    CurrentFinished = constructionContractEstimateBill.CurrentFinished
                });
            }
            return lstConstructionContractEstimateBillView;
        }
    }
}